package com.dailyblue.project.estate.controller;

import com.dailyblue.project.estate.commons.bean.Community;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.service.CommunityService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:CommunityController
 * @Date:2025/9/18 14:33
 */
@RestController
@RequestMapping("/community")
public class CommunityController {
    @Resource
    private CommunityService communityService;

    @PostMapping
    JsonResult saveCommunity(@RequestBody Community community) {
        return communityService.saveCommunity(community);
    }

    @GetMapping("/{id}")
    JsonResult findOne(@PathVariable("id") String id) {
        return communityService.findOneCommunity(id);
    }
    @GetMapping
    JsonResult findAll(){
        return communityService.findAllCommunity();
    }

    @DeleteMapping("/{id}")
    JsonResult deleteOne(@PathVariable("id")String id){
        return communityService.deleteCommunity(id);
    }

    @PutMapping
    JsonResult updateOne(@RequestBody Community community) {
        return communityService.updateCommunity(community);
    }
}
